package com.stlm2.dems.entity;

import com.stlm2.dems.entity.GoodSpecification;


import java.math.BigDecimal;

/**
 * Created by apple on 2017/8/24.
 */
public class ConfirmOrder {


    //商品id
    private Integer goodsId;
    //规格商品id
    private Integer goodsSpecification;
    //商品名称
    private String goodsName;
    //市场价
    private BigDecimal marketPrice;
    //会员价
    private BigDecimal salePrice;
    //赠送用户积分
    private BigDecimal ddPrice;
    //商品数量
    private Integer num;
    //总金额
    private BigDecimal totalMoney;
    //总积分
    private  BigDecimal totalIntegral;
    //是否需要识别码
    private Boolean hasLmie;






    public static ConfirmOrder convert(DdmGoods goods,int num){
        if(goods == null)
            return null;

        ConfirmOrder order = new ConfirmOrder();
        order.setGoodsId(goods.getId());
        order.setGoodsName(goods.getName());
        order.setSalePrice(goods.getMemberPrice());
        order.setDdPrice(goods.getDdPrice());
        order.setHasLmie(goods.getIsImie());
        order.setNum(num);
        order.setTotalMoney(goods.getMemberPrice().multiply(new BigDecimal(num)));
        order.setTotalIntegral(goods.getMemberPrice().multiply(new BigDecimal(num)));
        return order;

    }


    public static ConfirmOrder convertSpecification(DdmGoods goods, int num, GoodSpecification goodSpecification){
        if(goods == null)
            return null;
        if(goodSpecification==null)
            return null;

        ConfirmOrder order = new ConfirmOrder();
        order.setGoodsId(goods.getId());
        order.setGoodsName(goods.getName());
        order.setMarketPrice(goodSpecification.getMarketPrice());
        order.setSalePrice(goodSpecification.getMemberPrice());
        order.setDdPrice(goods.getDdPrice());//需改成规格的 叮当价
        order.setHasLmie(goods.getIsImie());
        order.setNum(num);
        order.setTotalIntegral(goodSpecification.getMemberPrice().multiply(new BigDecimal(num)));
        order.setTotalMoney(goodSpecification.getMemberPrice().multiply(new BigDecimal(num)));
        order.setGoodsSpecification(goodSpecification.getId());
        return order;

    }




    public Integer getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Integer goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public BigDecimal getMarketPrice() {
        return marketPrice;
    }

    public void setMarketPrice(BigDecimal marketPrice) {
        this.marketPrice = marketPrice;
    }

    public BigDecimal getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(BigDecimal salePrice) {
        this.salePrice = salePrice;
    }

    public BigDecimal getDdPrice() {
        return ddPrice;
    }

    public void setDdPrice(BigDecimal ddPrice) {
        this.ddPrice = ddPrice;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public BigDecimal getTotalMoney() {
        return totalMoney;
    }

    public void setTotalMoney(BigDecimal totalMoney) {
        this.totalMoney = totalMoney;
    }

    public BigDecimal getTotalIntegral() {
        return totalIntegral;
    }

    public void setTotalIntegral(BigDecimal totalIntegral) {
        this.totalIntegral = totalIntegral;
    }

    public Integer getGoodsSpecification() {
        return goodsSpecification;
    }

    public void setGoodsSpecification(Integer goodsSpecification) {
        this.goodsSpecification = goodsSpecification;
    }

    public Boolean getHasLmie() {
        return hasLmie;
    }

    public void setHasLmie(Boolean hasLmie) {
        this.hasLmie = hasLmie;
    }
}
